const query = require("../db/query");

//  获取医院 包含模糊搜索
const Getsoco = async (params) => {
    let sql = `select * from soco where nosocomium LIKE '%${params.nosocomium}%' and socolv LIKE '%${params.socolv}%' and sococity LIKE '%${params.sococity}%' and socostate LIKE '%${params.socostate}%' and socoadmin LIKE '%${params.socoadmin}%' ORDER BY socoid desc`;
    return await query(sql)
}

// 获取医院的等级
const Getsocolv = async () => {
    let sql = `select * from socolv`;
    return await query(sql)
}

// 添加医院
const Addsocolist = async (params) => {
    let sql = `INSERT INTO soco (nosocomium,socolv,sococity,socostate,socoadmin,socodescword,socoimage) VALUES ('${params.nosocomium}','${params.socolv}','${params.sococity}','${params.socostate}','${params.socoadmin}','${params.socodescword}','${params.socoimage}')`
    return await query(sql)
}

// 删除医院
const Delsocolist = async (params) => {
    let sql = `delete from soco where socoid = ${params.socoid}`
    return await query(sql)
}

// 修改医院数据
const Updatesocolist = async (params) => {
    let sql = `update soco set nosocomium='${params.nosocomium}',socolv='${params.socolv}',sococity='${params.sococity}',socostate='${params.socostate}',socoadmin='${params.socoadmin}',socodescword='${params.socodescword}',socoimage='${params.socoimage}' where socoid=${params.socoid}`
    return await query(sql)
}

module.exports = {
    Getsoco, //  获取医院 包含模糊搜索
    Getsocolv,// 获取医院等级
    Addsocolist,// 添加医院
    Delsocolist,// 删除医院
    Updatesocolist,// 修改医院数据
}